package com.share.PACManager;

import com.share.PACManager.model.CodeModel;
import com.share.PACManager.model.CompanyModel;
import com.share.PACManager.model.PersonModel;
import com.share.PACManager.model.PoliceModel;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;

public class RegPeopleInfoActivity extends BindActivity {

	private View btn_back;
	private AddPersonFunc mAddPersonFunc;
	private CompanyModel mCompany;
	private PoliceModel mPolice;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.reg_people_info);		
		findViews();
	}
	
	private void findViews(){
		btn_back = findViewById(R.id.id_btn_back);
        btn_back.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				finish();
			}        	
        });        
        
        mCompany = (CompanyModel) getIntent().getSerializableExtra("company_info");
        mPolice = (PoliceModel) getIntent().getSerializableExtra("police_info");
        mAddPersonFunc = new AddPersonFunc(this, mGlobal, mPolice, mCompany);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(resultCode == RESULT_OK)
		{
			if(requestCode == AddPersonFunc.CODE_READ_CARD)
			{
				PersonModel person = (PersonModel) data.getSerializableExtra("id_card_info");
				mAddPersonFunc.setPerson(person);
			}
			else if(requestCode == AddPersonFunc.CODE_SELECT_NATIVE)
			{
				CodeModel code = (CodeModel) data.getSerializableExtra("code_info");
				mAddPersonFunc.setPerson(code);
			}
			else if(requestCode == AddPersonFunc.CODE_TAKE_PHOTO)
			{
				mAddPersonFunc.savePhoto();
			}
		}
		super.onActivityResult(requestCode, resultCode, data);
	}
}
